package example.controller;

import example.common.Result;
import example.dto.SecondmentInfoDTO;
import example.dto.StateDTO;
import example.dto.TipDTO;
import example.service.ISecondmentContentInfoService;
import example.service.ISecondmentHeadInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@RequestMapping("/api/information")
public class SecondmentInfoController {

    @Resource
    private ISecondmentHeadInfoService secondmentHeadInfoService;

    @Resource
    private ISecondmentContentInfoService secondmentContentInfoService;


    /** 查询excel头部部分 */
    @GetMapping("/head/{id}")
    public Result listHead(@PathVariable("id") Long secondmentId) {
        return secondmentHeadInfoService.listHead(secondmentId);
    }

    /** 查询excel主体部分 */
    @PostMapping("/body")
    public Result listSecondmentInformation(@RequestBody SecondmentInfoDTO secondmentInfoDTO) {
        return secondmentContentInfoService.listSecondmentInformation(secondmentInfoDTO);
    }

    @GetMapping("/names/{id}")
    public Result getExcelNames(@PathVariable("id") Long secondmentId) {
        return secondmentContentInfoService.getExcelNames(secondmentId);
    }

    @GetMapping("/cancel/{id}")
    public Result cancelConfirm(@PathVariable("id") Long id) {
        return secondmentContentInfoService.cancelConfirm(id);
    }

    @GetMapping("/delete/{id}")
    public Result deleteSecondmentInformation(@PathVariable("id") Long id) {
        return secondmentContentInfoService.deleteSecondmentInformation(id);
    }

    @PostMapping("/change/state")
    public Result changeState(@RequestBody StateDTO stateDTO) {
        return secondmentContentInfoService.changeState(stateDTO);
    }

    @PostMapping("/change/tips")
    public Result changeTip(@RequestBody TipDTO tipDTO) {
        return secondmentContentInfoService.changeTip(tipDTO);
    }
}
